package _cn.com.jsr.translation.termidentifier.identifier;

import cn.com.jsr.translation.termidentifier.Dictionary;
import cn.com.jsr.translation.termidentifier.Seeker;
import cn.com.jsr.translation.termidentifier.identifier.Translate;
import junit.framework.TestCase;

public class _Translate extends TestCase{
	/**
	 * 测试目标：确保查找策略为：“不区分大小写，不合并空白”时，程序能够正确地执行翻译
	 */
	public void test1(){
		String src = "term translation  TERM translation    term   translation   TERM    translation";
		
		Dictionary dict = new Dictionary();
		dict.set("term  translation", "术语译文");
		
		Translate translate = new Translate();
		translate.setDictionary(dict);
		String tar = translate.seek(src, Seeker.CASE_INSENSITIVE);
		
		assertEquals(tar, "术语译文  术语译文    term   translation   TERM    translation");
	}
	
	/**
	 * 测试目标：确保查找策略为：“不区分大小写，合并空白”时，程序能够正确地执行翻译
	 */
	public void test2(){
		String src = "term translation  TERM translation    term   translation   TERM    translation";
		
		Dictionary dict = new Dictionary();
		dict.set("term  translation", "术语译文");
		
		Translate translate = new Translate();
		translate.setDictionary(dict);
		String tar = translate.seek(src, Seeker.CASE_INSENSITIVE | Seeker.MERGE_BLANK);
		
		assertEquals(tar, "术语译文  术语译文    术语译文   术语译文");
	}
	
	/**
	 * 测试目标：确保查找策略为：“区分大小写，不合并空白”时，程序能够正确地执行翻译
	 */
	public void test3(){
		String src = "term translation  TERM translation    term   translation   TERM    translation";
		
		Dictionary dict = new Dictionary();
		dict.set("term  translation", "术语译文");
		
		Translate translate = new Translate();
		translate.setDictionary(dict);
		String tar = translate.seek(src);
		
		assertEquals(tar, "术语译文  TERM translation    term   translation   TERM    translation");
	}
	
	/**
	 * 测试目标：确保查找策略为：“区分大小写，合并空白”时，程序能够正确地执行翻译
	 */
	public void test4(){
		String src = "term translation  TERM translation    term   translation   TERM    translation";
		
		Dictionary dict = new Dictionary();
		dict.set("term  translation", "术语译文");
		
		Translate translate = new Translate();
		translate.setDictionary(dict);
		String tar = translate.seek(src, Seeker.MERGE_BLANK);
		
		assertEquals(tar, "术语译文  TERM translation    术语译文   TERM    translation");
	}
}
